<template>
    <u-tabbar :value="currentTab" @change="handleTabChange" :fixed="true" :placeholder="true" activeColor="#29a74d"
        :safeAreaInsetBottom="true">

        <u-tabbar-item text="工具台" :icon="currentTab === 'workbench' ? '/static/sy1.png' : '/static/sy.png'"
            name="workbench"></u-tabbar-item>
        <u-tabbar-item text="工作流" :icon="currentTab === 'workflow' ? '/static/gjt1.png' : '/static/gjt.png'"
            name="workflow"></u-tabbar-item>
        <u-tabbar-item text="我的待办" :icon="currentTab === 'daiban' ? '/static/icon_fl.png' : '/static/icon_fl2.png'"
            name="daiban"></u-tabbar-item>
        <u-tabbar-item text="个人信息" :icon="currentTab === 'mine' ? '/static/wd1.png' : '/static/wd.png'"
            name="mine"></u-tabbar-item>
    </u-tabbar>
</template>

<script>
export default {
    name: 'CustomTabbar',
    props: {
        // 当前激活的tab
        currentTab: {
            type: String,
            default: 'workbench'
        }
    },
    methods: {
        handleTabChange(name) {
            if (this.currentTab === name) return;

            const tabMap = {
                workbench: '/pages/workbench/workbench',
                workflow: '/pages/workflow/workflow',
                daiban: '/pages/mydaiban/daiban',
                // mine: '/pages/mydaiban/daiban',
                mine: '/pages/mine/mine'
            };

            if (tabMap[name]) {
                uni.redirectTo({ url: tabMap[name] });
            }
        }
    }
}
</script>

<style lang="scss" scoped>
// 如果需要自定义样式可以在这里添加</style>